Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding metal_utils for iree_utils #1561

Merged
merged 12 commits into from
Jun 22, 2023
Merged

Conversation

Ranvirsv
Copy link
Contributor

Added metal_utils.py, changes IREE_DEVICE_MAP and IREE_TARGET_MAP to use metal, added a separate case to handel for metal device in compile_uitls.py

Passes 14 test using pytest -k metal, skips 16, xfail 16

@@ -0,0 +1,176 @@
# Copyright 2020 The Nod Team. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2023

# Adreno Targets
elif all(x in device_name for x in ("Adreno", "740")):
triple = f"adreno-a740-{system_os}"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove everything but the apple targets.

res_metal_flag = []
metal_triple_flag = None
for arg in extra_args:
if "-iree-metal-target-triple=" in arg:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix that

Abhishek-Varma and others added 3 commits June 20, 2023 10:53
…od-ai#1559)

-- It also modifies the mega_test.py script

Signed-off-by: Abhishek Varma <[email protected]>
…i#1560)

* Fix deprecation warning for unet config.

* Include PIL metadata instead of hidden imports in SD spec.
@Ranvirsv Ranvirsv requested a review from powderluv June 20, 2023 18:53
@@ -19,6 +19,7 @@ datas += copy_metadata('importlib_metadata')
datas += copy_metadata('torch-mlir')
datas += copy_metadata('omegaconf')
datas += copy_metadata('safetensors')
datas += copy_metadata('Pillow')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already in tree ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a git pull before pushing, realized later I should not have done that. So I got 2 commits from Ean and Abhishek

@powderluv
Copy link
Contributor

Please update the branch

@Ranvirsv Ranvirsv requested a review from powderluv June 21, 2023 00:37
powderluv
powderluv previously approved these changes Jun 21, 2023
@powderluv
Copy link
Contributor

Please run lint with black

@Ranvirsv
Copy link
Contributor Author

Ranvirsv commented Jun 21, 2023

Wanted to let you know, there are also some changes I was trying, to get stable diffusion running. (i.e. adding checks for metal device and metal flags). Let me know if they should be removed from here



def get_metal_device_name(device_num=0):
vulkaninfo_dump, _ = run_cmd("vulkaninfo")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wont work. I used

(shark.venv) ➜  web git:(main) ✗ sysctl -a | grep brand             
machdep.cpu.brand_string: Apple M1 Ultra

But I think Lei suggested using --dump_devices

print(
f"Found metal device {metal_device}. Using metal target triple {triple}"
)
return f"-iree-metal-target-triple={triple}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be -iree-metal-target-platform=

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, missed that one
Will fix it, and the vulkaninfo

@powderluv
Copy link
Contributor

ok to have the SD fixups too.

@powderluv
Copy link
Contributor

Please uninstall the VulkanSDK and vulkaninfo from your device to test :D

@Ranvirsv
Copy link
Contributor Author

I don't know how I can change this, since it returns --iree-vulkan-target-env, and I don't think there is a --iree-metal-target-env

if metal_triple_flag is not None:
        vulkan_target_env = get_vulkan_target_env_flag(meatal_triple_flag)
        res_metal_flag.append(vulkan_target_env)
    return res_metal_flag

@powderluv
Copy link
Contributor

For compile you still use vulkan

@powderluv powderluv merged commit 07c1e1d into nod-ai:main Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants